<template>
	<div id="returnorder">
	<h1 class="demo-form-inline" style="inline-heigth: 100px; text-align: center; margin: auto;">退货订单</h1>
			
		<!-- 表格 -->
		<el-table :data="receivingorderAll" style="width: 100%">
				<el-table-column prop="id" label="订单ID" width="100">
				</el-table-column>
				<el-table-column prop="orderId" label="订单编号">
				</el-table-column>
				<el-table-column prop="totalAmount" label="订单总金额">
				</el-table-column>
				<el-table-column prop="orderStatus" label="订单状态">
				</el-table-column>
				<el-table-column prop="conveyTag" label="配送标志">
				  <template slot-scope="scope">
					<span v-if="scope.row.conveyTag=='P001-2'">已提货</span>
				  </template>
				</el-table-column>
				<el-table-column prop="paymentMethod" label="支付方式">
			  <template slot-scope="scope">
				<span v-if="scope.row.paymentMethod=='P002-1'">余额支付</span>
				<span v-if="scope.row.paymentMethod=='P002-2'">微信支付</span>
				<span v-if="scope.row.paymentMethod=='P003'">现金支付</span>
			  </template>
				</el-table-column>
				<el-table-column prop="payStatus" label="支付状态">
				  <template slot-scope="scope">
					<span v-if="scope.row.payStatus=='K002-1'">等待支付</span>
					<span v-if="scope.row.payStatus=='K002-2'">支付失败</span>
					<span v-if="scope.row.payStatus=='K002-3'">支付成功</span>
				  </template>
				</el-table-column>
					  <!--操作列-->
					  <el-table-column label="操作">
						  <template slot-scope="scope">
							  <el-button size="small"
							  round
							  type="primary"
							  @click="viewdetails(scope.$index,scope.row)">查看详情</el-button>
							<el-button size="small"
							round 
							type="primary"
							@click="salesreturn(scope.$index,scope.row)">退货</el-button>
						  </template>
						</el-table-column>
					 </el-table>
			
			<!---分页组件-->
				 <el-pagination  style="inline-heigth: 100px; text-align: center; margin: auto;"
				 @size-change="handleSizeChange"
					  @current-change="handleCurrentChange"
					  :current-page="pageNo"
					  :page-sizes="pageSizeList"
					  :page-size="pageSize"
					  layout="total, sizes, prev, pager, next, jumper"
					  :total="total">
				 </el-pagination>
			<!-- 添加对话框 -->
								
			   <el-dialog title="查看详情订单" :visible.sync="makeFormVisible" >
				<el-table :data="receivingorderOne" style="width: 100%">
				<el-table-column prop="productName" label="商品名称">
				</el-table-column>
				<el-table-column prop="amount" label="数量">
				</el-table-column>
				<el-table-column prop="price" label="单价">
				</el-table-column>
				<el-table-column prop="subtotal" label="小计">
			</el-table-column>
			</el-table>
			    </el-dialog>
			
				</div>
				
				
			</template>
			
	<script>
				export default {
					      data() {
					        return {
								receivingorderAll: [],
							
								//回显对象
								receivingorderOne:[],
								//当前页号
								pageNo: 1,
								//当前页大小
								pageSize: 5,
								//总记录数
								total: 0,
								//页大小列表
								pageSizeList: [2, 5, 10, 20],
								//添加对话框的显示
								makeFormVisible: false,
								}
							},
							created() {
								// this.handleSizeChange(),
								// this.handleCurrentChange(),
								this.receivingorder()
								
								
								
							},
					         methods:{
								 // 页大小改变
								   handleSizeChange(val) {
								 	  this.pageSize = val
								 	  this.receivingorder()
									  
								   },
								   
								 //页号改变
								 handleCurrentChange(val) {
								 	this.pageNo = val
								 	// 重新查询
								 	this.receivingorder()
								 },
								 
								 //分页查询采购订单表
								 async receivingorder() { 
								 	// 用es6的解构函数
									console.log(1)
								 	const {data: res} = await this.$http.post
								 	(`/buy/order/pickupcx/${this.pageSize}/${this.pageNo}`)
								 	this.receivingorderAll = res.list
								 	this.total = res.total
								 },
								 
								 //点击查看详情
								 async viewdetails(index,row) {
								 	// 用es6的解构函数
								 //显示表
								 this.makeFormVisible = true
								 const {data: res} = await this.$http.post(`/buy/orderDetails/orderdetaid/${row.id}`)
								 console.log(123456,res)
								     this.receivingorderOne=res
									 },
								//点击货
								async salesreturn(index,row) {
									// 用es6的解构函数
									const {data: res} = await this.$http.post(`/buy/order/pickupupdate/${row.id}`)
														console.log(res)
								//	this.receiving()
								if(res!='error'){
								 this.$message({
										   showClose: true,
										   message: '提货成功',
										   type: 'success'
										 });
										// this.pickup()
								}else{
								 this.$message({
										   showClose: true,
										   message: '提货失败',
										   type: 'success'
										 });
								}	 
									 
								 },
								 
								 //点击审核
								 async passtheaudit(index,row) {
								// 用es6的解构函数
								const {data: res} = await this.$http.post(`/buy/orderDetails/passtheaudit/${row.id}`)
								console.log(res)
								 //	this.receiving()
								 if(res!='error'){
									 this.$message({
											   showClose: true,
											   message: '审核成功',
											   type: 'success'
											 });
											 this.shohuodindan()
								 }else{
										 this.$message({
												   showClose: true,
												   message: '审核失败',
												   type: 'success'
												 });
								 }
							//this.$route.path('/shohuodindan')
								 },
							 }
					        }
					      
					    
					
				</script>